package com.tj.collection.controller;

import com.alibaba.csp.sentinel.annotation.SentinelResource;
import com.tj.collection.aop.anno.VisitorAccessible;
import com.tj.collection.task.ChatterDataTask;
import com.tj.collection.task.ModelDataTask;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;

/**
 * Created with IntelliJ IDEA.
 * User: sm
 * Date: 2017/9/11
 * Time: 下午4:45
 */
@Controller
public class OkController {

//    private static final Loggerlogger = LoggerFactory.getLogger(OkController.class);

    private static final Logger logger = LoggerFactory.getLogger(OkController.class);

    @Resource
    private ModelDataTask modelDataTask;
    @Resource
    private ChatterDataTask chatterDataTask;

    @VisitorAccessible
    @RequestMapping("/ok")
    @ResponseBody
    @SentinelResource("1989")
    public String ok() {
        return "post-lending,ok";
    }

    @VisitorAccessible
    @RequestMapping("/logok")
    @ResponseBody
    public String logok() {
        logger.info("testok,AAA111111222222333333,");
        return "ok";
    }

    @VisitorAccessible
    @RequestMapping("/configok")
    @ResponseBody
    public String configok() {

        return "ok,";
    }

    @VisitorAccessible
    @RequestMapping("/modelDataTask")
    @ResponseBody
    public String modelDataTask() {
        modelDataTask.modelLike();
        return "ok";
    }

    @VisitorAccessible
    @RequestMapping("/modelLike")
    @ResponseBody
    public String modelLike() {
        modelDataTask.run();
        return "ok";
    }

    @VisitorAccessible
    @RequestMapping("/chatterDataTask")
    @ResponseBody
    public String chatterDataTask() {
        chatterDataTask.chatterData();
        return "ok";
    }

    @VisitorAccessible
    @RequestMapping("/userOnlineData")
    @ResponseBody
    public String userOnlineData() {
        chatterDataTask.userOnlineData();
        return "ok";
    }
}
